﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Practices.Composite.Presentation.Commands;

namespace Core.Infrastructure.CommandExtensions
{
    public class ItemsControlDragEnterCommandBehavior : CommandBehaviorBase<ItemsControl>
    {
        public ItemsControlDragEnterCommandBehavior(ItemsControl targetObject) : base(targetObject)
        {
            targetObject.DragEnter += new DragEventHandler(TargetObjectDragEnter);
        }

        void TargetObjectDragEnter(object sender, DragEventArgs e)
        {
            var itemsControl = sender as ItemsControl;
            if (itemsControl != null)
                CommandParameter = (itemsControl.Items[0] as Grid).Children[0];
            base.ExecuteCommand();
        }
    }
}
